package org.alvin.xl.hlht.client;

import com.alibaba.fastjson.JSONObject;
import org.alvin.mini_inject.annotations.MiniComponent;
import org.alvin.mini_inject.annotations.MiniInject;
import org.alvin.xl.hlht.utils.AESUtil;
import org.alvin.xl.hlht.utils.HmacMD5;


/**
 * 解密工具
 */
@MiniComponent
public class HlhtClientDecodeSimulator {
    @MiniInject
    private HlhtConfigSimulator configSimulator;

    public String decode(String sourceData) throws Exception {
        JSONObject data = JSONObject.parseObject(sourceData);
        String encryptedData = data.getString("Data");
        System.out.println(configSimulator.getServerdataKey() + "   ------------   " + configSimulator.getServerdataIv());
        return AESUtil.decrypt(encryptedData, configSimulator.getServerdataKey(), configSimulator.getServerdataIv());
    }


    public static void main(String[] args) {
        String data = "uexBhndQXEB+WtoPZBbaRg==";
        String dataKey = "8z8LOYE7HRBM7gz0";
        String iv = "Ts0EvOdNtZC7BNGL";
        String res = AESUtil.decrypt(data, dataKey, iv);
        System.out.println(res);
    }


}
